


#ifndef PF_CONSTRUCTIONLINE_H
#define PF_CONSTRUCTIONLINE_H

#include "pf_atomicentity.h"
#include "pf_vector.h"
#include "lx_Export.h"

/**
 * Holds the data that defines a construction line (a line
 * which is not limited to both directions).
 */
class LX_EXPORT PF_ConstructionLineAttribute {
public:
    /**
     * Default constructor. Leaves the data object uninitialized.
     */
    PF_ConstructionLineAttribute() {}

    PF_ConstructionLineAttribute(const PF_Vector& point1,
                            const PF_Vector& point2) {

        this->point1 = point1;
        this->point2 = point2;
    }

    friend class PF_ConstructionLine;

    friend std::ostream& operator << (std::ostream& os,
                                      const PF_ConstructionLineAttribute& ld) {

        os << "(" << ld.point1 <<
        "/" << ld.point2 <<
        ")";
        return os;
    }

private:
    PF_Vector point1;
    PF_Vector point2;
};


/**
 * Class for a construction line entity.
 *

 */
class LX_EXPORT PF_ConstructionLine : public PF_AtomicEntity {
public:
    PF_ConstructionLine(PF_Container* parent,
                        const PF_ConstructionLineAttribute& d);

    virtual PF_Entity* clone();

    virtual ~PF_ConstructionLine();

    /**	@return LX_Define::EntityConstructionLine */
    virtual LX_Define::EntityType rtti() const {
        return LX_Define::EntityConstructionLine;
    }
    
	/** 
	 * @todo
	 * @return Start point of the entity. 
	 */
    virtual PF_Vector getStartpoint() const {
        return PF_Vector(false);
    }
    /** 
	 * @todo
	 * @return End point of the entity. 
	 */
    virtual PF_Vector getEndpoint() const {
        return PF_Vector(false);
    }

    /** @return Copy of data that defines the line. */
    PF_ConstructionLineAttribute getData() const {
        return data;
    }

    /** @return First definition point. */
    PF_Vector getPoint1() const {
        return data.point1;
    }
    /** @return Second definition point. */
    PF_Vector getPoint2() const {
        return data.point2;
    }

    virtual PF_Vector getNearestEndpoint(const PF_Vector& coord,
                                         double* dist = NULL);
    virtual PF_Vector getNearestPointOnEntity(const PF_Vector& coord,
            bool onEntity = true, double* dist = NULL, PF_Entity** entity=NULL);
    virtual PF_Vector getNearestCenter(const PF_Vector& coord,
                                       double* dist = NULL);
    virtual PF_Vector getNearestMiddle(const PF_Vector& coord,
                                       double* dist = NULL);
    virtual PF_Vector getNearestDist(double distance,
                                     const PF_Vector& coord,
                                     double* dist = NULL);
    virtual double getDistanceToPoint(const PF_Vector& coord,
                                      PF_Entity** entity=NULL,
                                      LX_Define::ResolveLevel level=LX_Define::ResolveNone,
									  double solidDist = LX_DOUBLEMAX);

    virtual void move(PF_Vector offset);
    virtual void rotate(PF_Vector center, double angle);
    virtual void scale(PF_Vector center, PF_Vector factor);
    virtual void mirror(PF_Vector axisPoint1, PF_Vector axisPoint2);

    virtual void draw(PF_Painter* /*painter*/, PF_GraphicView* /*view*/, 
		double /*patternOffset*/) {}

    friend std::ostream& operator << (std::ostream& os,
                                      const PF_ConstructionLine& l);

    virtual void calculateBorders();

protected:
    PF_ConstructionLineAttribute data;
};

#endif
